package cn.itsource.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * User: liyu
 * Date: 2022/12/10 星期六 11:10:08
 * Description:   配置类
 */
@Configuration    // 表名当前类是一个配置类
public class   WebMvcConfig implements WebMvcConfigurer {

    // 注入自定义拦截器的依赖
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)     // 添加需要拦截的拦截器名称
                .addPathPatterns("/**")    // 表示拦截所有的路径
                .excludePathPatterns("/login/**")//放行登陆
                .excludePathPatterns("/html/**");//放行所有html开头的请求
    }
}
